<ui:composition template="/templates/default.xhtml"
				xmlns="http://www.w3.org/1999/xhtml"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:f="http://java.sun.com/jsf/core"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:fn="http://java.sun.com/jsp/jstl/functions"
				xmlns:o="http://openfaces.org/"
				xmlns:c="http://java.sun.com/jstl/core">

	<ui:param name="crud" value="#{locationCrud}" />	
	
	<ui:define name="listing">
		<ui:include src="list.xhtml" />
	</ui:define>
    
	<ui:define name="display">
	
		<h:outputText value="#{navController.breadcrumbTrail}" />	
	
		<h1>#{msg.locationEdit}</h1>
	    <h:messages id="errors" globalOnly="true" />
	    <h:form id="form">
	    	<h:panelGrid columns="4">
		    	<h:outputText value="#{msg.locationId}:"/>
		    	<h:outputText />
	            <h:inputText styleClass="location" autocomplete="off" id="locationExtId" value="#{locationCrud.item.extId}" converter="#{defaultConverter}" disabled="true"/>
	            <h:message for="locationExtId" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
	
	            <h:outputText value="#{locationHierarchyService.lowestLevel.name}:"/>
	            <h:outputText />
	            <h:inputText styleClass="locationName" autocomplete="off" id="level" value="#{locationCrud.item.locationLevel.extId}"/>
	            <h:message for="level" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
	
	            <h:outputText value="#{msg.locationName}:"/>
	            <h:outputText />
	           	<h:inputText id="locationName" value="#{locationCrud.item.locationName}" converter="#{defaultConverter}" />
	            <h:message for="locationName" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
	
				<h:outputText value="Location Head:"/>
				<h:outputText />
	            <h:inputText styleClass="individual" autocomplete="off" id="locationHead" value="#{locationCrud.item.locationHead}" converter="#{individualExtIdConverter}" />
	            <h:message for="locationHead" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
				
			    <h:outputText value="#{msg.locationType}:"/>
             	<img class="clickable" onclick="O$('popupWindowForLocType').showCentered();" src="#{request.contextPath}/resources/images/question.png" />
                <h:inputText id="locationType" value="#{locationCrud.item.locationType}" converter="#{defaultConverter}" />
             	<h:message for="locationType" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
	                      
	            <h:outputText value="#{msg.locationLatitude}:"/>
                <h:outputText />
                <h:inputText id="latitude" value="#{locationCrud.item.latitude}" converter="#{defaultConverter}" />
                <h:message for="latitude" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                
                <h:outputText value="#{msg.locationLongitude}:"/>
                <h:outputText />
                <h:inputText id="longitude" value="#{locationCrud.item.longitude}" converter="#{defaultConverter}" />
                <h:message for="longitude" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                
                <h:outputText value="#{msg.locationAccuracy}:"/>
                <h:outputText />
                <h:inputText id="accuracy" value="#{locationCrud.item.accuracy}" converter="#{defaultConverter}" />
                <h:message for="accuracy" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                
                <h:outputText value="#{msg.locationAltitude}:"/>
                <h:outputText />
                <h:inputText id="altitude" value="#{locationCrud.item.altitude}" converter="#{defaultConverter}" />
                <h:message for="altitude" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>          
	                         
	           	<h:outputText value="#{msg.fieldWorkerId}:"/>
	           	<h:outputText />
	           	<h:inputText styleClass="collectedBy" autocomplete="off" id="collectedBy" value="#{locationCrud.item.collectedBy}" converter="#{fieldWorkerExtIdConverter}"/>
	           	<h:message for="collectedBy" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
			</h:panelGrid>
	        <script>document.getElementById('form:level').focus();</script>
	        <br />
	        
	        <h:commandButton action="#{locationCrud.edit}" value="#{msg.lblSave}">
	        	<f:setPropertyActionListener target="#{jsfService.itemId}" value="#{locationCrud.item.uuid}" />
	      	</h:commandButton>
	     </h:form>
	 </ui:define>
 </ui:composition>
